//package com.briup.ptp.web.interceptor;
//
//
//import com.briup.ptp.utils.JWTUtils;
//import com.briup.ptp.utils.ResultCode;
//import com.briup.ptp.utils.SMSException;
//import io.jsonwebtoken.ExpiredJwtException;
//import io.jsonwebtoken.MalformedJwtException;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * @Classname LoginCheckinterceptor
// * @Description TODO
// * @Date 2024/1/9 16:50
// * @Created by 孙雅如
// * @Version v1.0.0
// */
//@Component
//public class LoginCheckInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        if(request.getMethod().equals("OPTIONS")){
//            return true;
//        }
//        String token = request.getHeader("token");
//        if(token==null){
//            throw  new SMSException(ResultCode.USER_NOT_LOGIN);
//        }
//        try{
//            JWTUtils.parse(token);
//        }catch (ExpiredJwtException e){
//            throw new SMSException(ResultCode.TOKEN_EXPIRED);
//        }catch (MalformedJwtException e1){
//            throw new SMSException(ResultCode.TOKEN_INVALID);
//        }
//
//        return true;
//    }
//
//
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//
//    }
//}
